#include "Source.h"
#include "TextBook.h"
#include <string>
#include <vector>

std::string TextBook::getLine(size_t index) {
	return text.at(index);
}

void TextBook::setLine(std::string line, size_t index) {
	text.at(index) = line;
}

void TextBook::addLine(std::string line) {
	text.push_back(line);
}

size_t TextBook::getBookSize() {
	return text.size();
}

void TextBook::addPointIndex(int c) {
	pointIndex.push_back(c);
}

int TextBook::getPointIndex(int line) {
	return pointIndex.at(line);
}

int TextBook::getLinesRed() {
	return linesRed;
}

void TextBook::setLinesRed(int i) {
	linesRed = i;
}


int TextBook::getLineByPointIndex(int pi) {
	if (pointIndex.size() == 0) 
		return 0;
	
	int count = 0;

	while (pointIndex.at(count) <= pi) {
		++count;
		if (count + 2 >= pointIndex.size()) 
			return pointIndex.size() - 1;
	}

	return count;
	
}
